import BatchImportExportConfigAPI from "@/api/batchImportExportConfig/index";
import type {BatchImportExportConfigQuery} from "@/api/batchImportExportConfig/model";
import type {IContentConfig} from "@/components/PageContent/index.vue";

const contentConfig = (params?: any): IContentConfig<BatchImportExportConfigQuery> => {
    return {
        pageName: "batchImportExportConfig",
        table: {
            border: true,
            highlightCurrentRow: true,
        },
        indexAction: function (params) {
            return BatchImportExportConfigAPI.query(params);
        },
        deleteAction: function (ids) {
            return BatchImportExportConfigAPI.delete(ids);
        },
        pk: "id",
        toolbar: ["add", "delete"],
        cols: [
            {width: 50, type: "selection"},
            {
                label: "表名",
                align: "center",
                prop: "tableName",
                template: "list",
                async initFn() {
                    this.selectList = await params?.getAllTableInfo();
                }
            },
            {label: "备注信息", align: "center", prop: "remark"},
            {label: "创建时间", align: "center", prop: "createTime",expand: true},
            {label: "更新时间", align: "center", prop: "updateTime",expand: true},
            {
                width: 120,
                label: "模板类型",
                align: "center",
                prop: "type",
                template: "list",
                selectList: [{value: '0', label: '导入', tag: 'primary'}, {value: '1', label: '导出', tag: 'success'}]
            },
            {
                width: 120,
                label: "状态",
                align: "center",
                prop: "status",
                template: "list",
                selectList: [
                    {value: '0', label: '待初始化', tag: 'info'},
                    { value: '1', label: '启用', tag: 'success'},
                    { value: '2', label: '禁用', tag: 'danger'},
                ]
            },
            {
                width: 120,
                label: "导入类型",
                align: "center",
                prop: "importType",
                template: "custom",
                slotName: "importTypeSlot",
            },

            {width: 120,label: "字段映射配置", align: "center", prop: "id", template: "custom", slotName: "initFieldMapping"},
            {
                label: "操作",
                fixed: "right",
                width: 130,
                align: "center",
                template: "tool"
            },
        ],
    }
};

export default contentConfig;